package keqiang.com.kq_flutter_core_widget.util.wechat;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.keqiang.base.Logger;

/**
 * 微信结果回调界面
 *
 * @author Created by 汪高皖 on 2018/12/10 0010 09:27
 */
public class WXCallbackActivity extends Activity {
    public static final String TAG = WXCallbackActivity.class.getSimpleName();
    
    private boolean isFinish = false;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Logger.d(TAG, "界面创建");
        WXAPI.handIntent(getIntent());
        isFinish = true;
        finish();
    }
    
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        Logger.d(TAG, "执行onNewIntent");
        WXAPI.handIntent(intent);
        isFinish = true;
        finish();
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        if (!isFinish) {
            // 进入这里，就是分享时/授权登录时，直接把微信杀死
            WXAPI.handIntent(null);
        }
        finish();
    }
    
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Logger.e(TAG, "界面销毁");
    }
}
